Skip to content

feat(map): Handle json.Number when merging maps #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elliotcourant
Copy link

If you unmarshall a json object using the json.Decoder and the UseNumber function, it will create numbers on the map as a json.Number object. This object has helper functions for handling ints and floats. So if a json.Number is encountered, try to handle the type of the number based on the destination.

This partially addresses #138 even though it is an old issue.

If this is not something you'd like to have built in that's totally fine, I'm happy to fork or try to build a transformer for this. But figured a PR would be best since others have asked for it in a way and this seemed like a correct way to do it.

If you unmarshall a json object using the json.Decoder and the UseNumber
function, it will create numbers on the map as a `json.Number` object.
This object has helper functions for handling ints and floats. So if a
json.Number is encountered, try to handle the type of the number based
on the destination.
@darccio
Copy link
Owner

darccio commented May 5, 2025

Thanks @elliotcourant. I'll give it a thought.

@elliotcourant
Copy link
Author

Thank you I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants